<html>
    <head>
        <script src="../../resources/js-test.js"></script>
        <script>
        function log(msg)
        {
            document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
        }

        var iframe;
        var iframeDocument;
        var iframeScrollTopAfterAnchor = 0;

        function test()
        {
            if (window.testRunner) {
                testRunner.waitUntilDone();
                testRunner.dumpAsText();
            }

            iframe = document.getElementById('NoScrolliFrame');
            iframeDocument = iframe.contentDocument;
            iframeScrollTopAfterAnchor = 0;

            var clickme = iframeDocument.getElementById('clickme');
            var x = iframe.offsetLeft + clickme.offsetLeft + 7;
            var y = iframe.offsetTop + clickme.offsetTop + 7;
            if (window.eventSender) {
                eventSender.dragMode = false;
                eventSender.mouseMoveTo(x, y);
                eventSender.mouseDown();
                eventSender.mouseUp();
            }
            setTimeout(autoscrollTestPart1, 0);
        }

        function autoscrollTestPart1()
        {
            iframeScrollTopAfterAnchor = iframeDocument.scrollingElement.scrollTop;
            if (iframeDocument.scrollingElement.scrollTop == 0)
                log("FAILED: anchor clicking within non-scrollable inner frame failed.");

            if (window.eventSender) {
                var textInIframe = iframeDocument.getElementById('textInFrame');
                var x = iframe.offsetLeft + textInIframe.offsetLeft - iframeDocument.scrollingElement.scrollLeft + 7;
                var y = iframe.offsetTop + textInIframe.offsetTop - iframeDocument.scrollingElement.scrollTop + 7;
                eventSender.dragMode = false;
                eventSender.mouseMoveTo(x, y);
                eventSender.mouseDown();
                eventSender.mouseMoveTo(x, y - 10);
                y = iframe.offsetTop;
                eventSender.mouseMoveTo(x, y - 5);
            }
            setTimeout(autoscrollTestPart2, 100);
        }

        function autoscrollTestPart2()
        {
            if (window.eventSender)
                eventSender.mouseUp();

            log("Document whose HTML or BODY tags have overflow:hidden should not autoscroll.");
            if (iframeScrollTopAfterAnchor == iframeDocument.scrollingElement.scrollTop)
                log("PASSED: the autoscroll has not happened.");
            else
                log("FAILED: the autoscroll has happened.");

            if (window.testRunner)
                testRunner.notifyDone();
        }
        </script>
    </head>
<body onload="test()">
    <iframe id="NoScrolliFrame" style="height: 150px; width: 150px" src="resources/big-page-with-overflow-hidden-and-anchor-scroll.html" ></iframe>
    <div id="console"></div>
</body>
</html>
